package dao

import (
	"github.com/go-xorm/xorm"
	log "github.com/sirupsen/logrus"
	"simulationFulu/models"
	"xorm.io/core"
)

//定义orm引擎
var x *xorm.Engine

func init() {
	var err error
	x, err = xorm.NewEngine("mysql", "root:123456@tcp(192.168.12.118:3306)/fuluTestDb?charset=utf8mb4")
	//设置日志显示
	x.ShowSQL(true)
	x.SetLogLevel(core.LOG_DEBUG)
	if err != nil {
		log.Fatal("数据库连接失败:", err)
	}
	if err := x.Sync2(
		new(models.Product),
		new(models.ProOrder),
		new(models.Card)); err != nil {
		log.Fatal("数据表同步失败:", err)
	}
}
